<?php
/**
* Save real Estate Project
* @author trungdt
* @since June 25, 2011
* 
* Change logs
* 
*/

if (!defined('EXPONENT')) exit('');

$project = null;
if (isset($_POST['id'])) {
	$project = $db->selectObject('duan','id='.intval($_POST['id']));
	if ($project) {
		$loc = unserialize($project->location_data);
	}
} 

if (exponent_permissions_check('administrate',$loc) || ($project && exponent_permissions_check('edit',$loc)) || (!$project && exponent_permissions_check('create',$loc))) {
	$project = duan_duan::update($_POST,$project, $loc);
	$project->location_data = serialize($loc);

	if (isset($project->id)) {
		$db->updateObject($project,'duan');
	} else {
		$db->insertObject($project,'duan');
	}
	exponent_flow_redirect();
} else {
	echo SITE_404_HTML;
}

?>